package org.sunrise.game.center.client;

import io.netty.channel.ChannelHandlerContext;
import org.sunrise.game.common.log.LogCore;
import org.sunrise.game.common.network.client.BaseClientHandler;

public class ReportClientHandler extends BaseClientHandler {

    public ReportClientHandler(String nodeId) {
        super(nodeId);
    }

    /**
     * 与中心服断开，需要重连
     */
    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        super.channelInactive(ctx);
        LogCore.Client.error("server disconnected, cur NodeId = { {} }, remoteAddress = {}", getNodeId(), ctx.channel().remoteAddress());

        // 启动重连
        ReportClientManager.getReportClient(getNodeId()).reConnectMaster();
    }
}
